<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="root">
    <input value="1" type="text" id="a">+
    <input value="2" type="text" id="b">
    <button>=</button>
    <input type="text" id="sum">
</div>
</body>
<script>
	document.querySelector("button").onclick = function(){
		const xhr = new XMLHttpRequest();
		xhr.responseType = "json";
		const a = document.querySelector("#a").value;
		const b = document.querySelector("#b").value;
		xhr.open("get",`/sum?a=${a}&b=${b}`);
		xhr.send();
		xhr.onload = function(){
			console.log(xhr.response);
			document.querySelector("#sum").value = xhr.response.sum;
		}
	}
</script>
</html>